<template>
  <div class="container">
    <div class="screen" ref="screen">
      <div class="top">
        <Top></Top>
      </div>
      <div class="main">
        <div class="left">
          <Tourist class="tourist"></Tourist>
          <Sex class="sex"></Sex>
          <Age class="age"></Age>
        </div>
        <div class="center">
          <Map class="map"></Map>
          <Line class="line"></Line>
        </div>
        <div class="right">右侧</div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
  import { onMounted, ref } from 'vue'
  import Top from './components/top/index.vue'
  import Map from './components/map/index.vue'
  import Line from './components/line/index.vue'
  import Tourist from './components/tourist/index.vue'
  import Age from './components/age/index.vue'
  import Sex from './components/sex/index.vue'

  //获取数据大屏展示内容的盒子元素实例
  let screen = ref()
  onMounted(() => {
    screen.value.style.transform = `scale(${getScale()}) translate(-50%, -50%)`
  })
  //定义大屏缩放比例
  function getScale(w = 1920, h = 1080) {
    const ww = window.innerWidth / w
    const wh = window.innerHeight / h
    return ww < wh ? ww : wh
  }
  //监听视口变化
  window.onresize = () => {
    screen.value.style.transform = `scale(${getScale()} translate(-50%, 50%))`
  }
</script>

<style scoped lang="scss">
  .container {
    width: 100vw;
    height: 100vh;
    background: url(./images/bg.png) no-repeat;
    background-size: cover;
    .screen {
      position: fixed;
      width: 1920px;
      height: 1080px;
      left: 50%;
      top: 50%;
      transform-origin: left top;
      .top {
        width: 100%;
        height: 40px;
      }
      .main {
        display: flex;
        .right {
          flex: 1;
          display: flex;
          flex-direction: column;
          margin-left: 20px;
          background: green;
        }
        .left {
          display: flex;
          flex-direction: column;
          flex: 1;
          height: 1040px;
          .tourist {
            flex: 1.2;
          }

          .sex {
            flex: 1;
          }

          .age {
            flex: 1;
          }
        }
        .center {
          flex: 1.8;
          display: flex;
          flex-direction: column;
          margin-left: 20px;
          .map {
            flex: 4;
          }
          .line {
            flex: 1;
          }
        }
      }
    }
  }
</style>
